package com.aspose.cells;

import java.util.HashMap;

class zaff {
   private static char[] b = new char[]{'\'', '='};
   static HashMap a = new HashMap();
   private static final com.aspose.cells.b.c.a.za c = new com.aspose.cells.b.c.a.za(new String[]{"center", "distributed", "justify", "left", "right", "center-across", "fill", "middle", "top"});

   static boolean a(Style var0, Style var1) {
      if (var0 == null) {
         return false;
      } else {
         boolean var2 = (var0.getForegroundColor().getR() & 255) != 255 || (var0.getForegroundColor().getG() & 255) != 255 || (var0.getForegroundColor().getB() & 255) != 255;
         boolean var3 = (var0.getForegroundColor().toArgb() & 16777215) != (var1.getForegroundColor().toArgb() & 16777215) || var0.getPattern() != 0;
         if (var2 && var3) {
            return true;
         } else if (var0.d() == null) {
            return false;
         } else {
            return var0.getBorders().getByBorderType(4).getLineStyle() != 0 || var0.getBorders().getByBorderType(8).getLineStyle() != 0 || var0.getBorders().getByBorderType(1).getLineStyle() != 0 || var0.getBorders().getByBorderType(2).getLineStyle() != 0;
         }
      }
   }

   static String a(int var0, int var1) {
      StringBuilder var2 = new StringBuilder(var1);
      String var3 = com.aspose.cells.b.a.zo.a(var0);
      var2.append(var3);

      for(int var4 = 0; var4 < var1 - var3.length(); ++var4) {
         var2.insert(0, '0');
      }

      return com.aspose.cells.b.a.zr.a(var2);
   }

   static String a(String var0) {
      if (var0 == null) {
         return null;
      } else if (var0.length() == 0) {
         return "";
      } else {
         StringBuilder var1 = new StringBuilder(var0.length());

         for(int var2 = 0; var2 < var0.length(); ++var2) {
            char var3 = var0.charAt(var2);
            String var4 = a(var3);
            if (var4 != null) {
               var1.append(var4);
            } else {
               var1.append(var3);
            }
         }

         return com.aspose.cells.b.a.zr.a(var1);
      }
   }

   private static String a(char var0) {
      switch(var0) {
      case '\n':
         return "&#10;";
      case '\r':
         return "&#13;";
      case '"':
         return "&quot;";
      case '&':
         return "&amp;";
      case '<':
         return "&lt;";
      case '>':
         return "&gt;";
      default:
         return null;
      }
   }

   private static String b(char var0) {
      switch(var0) {
      case '\n':
         return "&#10;";
      case '\r':
         return "&#13;";
      case ' ':
         return "&nbsp;";
      case '"':
         return "&quot;";
      case '&':
         return "&amp;";
      case '<':
         return "&lt;";
      case '>':
         return "&gt;";
      default:
         return null;
      }
   }

   static String b(String var0) {
      if (var0 == null) {
         return null;
      } else {
         return var0.length() == 0 ? "" : com.aspose.cells.b.a.zv.a(com.aspose.cells.b.a.zv.a(com.aspose.cells.b.a.zv.a(com.aspose.cells.b.a.zv.a(com.aspose.cells.b.a.zv.a(com.aspose.cells.b.a.zv.a(com.aspose.cells.b.a.zv.a(var0, "&amp;", "&"), "&#10;", "\n"), "&#13;", "\r"), "&quot;", "\""), "&lt;", "<"), "&gt;", ">"), "&nbsp;", " ");
      }
   }

   private static String c(char var0) {
      switch(var0) {
      case ' ':
      case '#':
      case '%':
      case '&':
      case '+':
      case '/':
      case '=':
      case '?':
         return "_";
      default:
         return null;
      }
   }

   static String c(String var0) {
      if (var0 == null) {
         return null;
      } else if (var0.length() == 0) {
         return "";
      } else {
         StringBuilder var1 = new StringBuilder(var0.length());

         for(int var2 = 0; var2 < var0.length(); ++var2) {
            char var3 = var0.charAt(var2);
            String var4 = b(var3);
            if (var4 != null) {
               var1.append(var4);
            } else {
               var1.append(var3);
            }
         }

         return com.aspose.cells.b.a.zr.a(var1);
      }
   }

   static String d(String var0) {
      if (var0 == null) {
         return null;
      } else if (var0.length() == 0) {
         return "";
      } else {
         StringBuilder var1 = new StringBuilder(var0.length());

         for(int var2 = 0; var2 < var0.length(); ++var2) {
            char var3 = var0.charAt(var2);
            String var4 = c(var3);
            if (var4 != null) {
               var1.append(var4);
            } else {
               var1.append(var3);
            }
         }

         return com.aspose.cells.b.a.zr.a(var1);
      }
   }

   static String[] a(Cell var0) {
      int var1 = var0.c.c;
      if (var1 == 5) {
         var1 = ((zyi)var0.c.d).c;
      }

      if (var1 == 0) {
         return null;
      } else {
         String[] var2 = new String[3];
         switch(var1) {
         case 1:
         case 6:
            var2[0] = "num";
            var2[1] = var0.j();
            Style var3 = var0.p();
            if (var3.r() != 0 || var3.s() != null && !"".equals(var3.s())) {
               var2[2] = var0.c.a(true);
            }
            break;
         case 2:
            var2[0] = "bool";
            var2[1] = var0.getBoolValue() ? "TRUE" : "FALSE";
            var2[2] = var2[1];
            break;
         case 3:
            var2[0] = "err";
            var2[1] = "#VALUE!";
            if (var0.getValue() != null) {
               var2[1] = var0.c.f();
            }

            var2[2] = var2[1];
            break;
         case 4:
         case 5:
         default:
            var2[0] = "str";
            var2[1] = var0.j();
            var2[2] = var2[1];
         }

         return var2;
      }
   }

   static String a(int var0) {
      switch(var0) {
      case 0:
         return "";
      case 1:
         return "text-decoration:underline;";
      case 2:
         return "text-decoration:underline; mso-text-underline:double;";
      case 3:
         return "text-decoration:underline; ms-text-underline:single-accounting;";
      case 4:
         return "text-decoration:underline; mso-text-underline:double-accounting;";
      default:
         return "";
      }
   }

   static String b(int var0) {
      switch(var0) {
      case 1:
         return "text-align:center";
      case 2:
         return "text-align:center-across";
      case 3:
         return "text-align:distributed";
      case 4:
         return "text-align:fill";
      case 5:
         return "text-align:general";
      case 6:
         return "text-align:justify";
      case 7:
         return "text-align:left";
      case 8:
         return "text-align:right";
      default:
         return null;
      }
   }

   static int e(String var0) {
      switch(c.a(var0)) {
      case 0:
         return 1;
      case 1:
         return 3;
      case 2:
         return 6;
      case 3:
         return 7;
      case 4:
         return 8;
      case 5:
         return 2;
      case 6:
         return 4;
      default:
         return 5;
      }
   }

   static int f(String var0) {
      switch(c.a(var0)) {
      case 1:
         return 3;
      case 2:
         return 6;
      case 3:
      case 4:
      case 5:
      case 6:
      default:
         return 0;
      case 7:
         return 1;
      case 8:
         return 9;
      }
   }

   static String c(int var0) {
      switch(var0) {
      case 0:
         return "vertical-align:bottom";
      case 1:
         return "vertical-align:middle";
      case 2:
      case 4:
      case 5:
      case 7:
      case 8:
      default:
         return "";
      case 3:
         return "vertical-align:distributed";
      case 6:
         return "vertical-align:justify";
      case 9:
         return "vertical-align:top";
      }
   }

   static long d(int var0) {
      return (long)(var0 * 32);
   }

   static boolean a(WorksheetCollection var0, Hyperlink var1, String[] var2, CellArea[] var3) {
      if (var1.a(var0) == 2) {
         try {
            String var4 = var1.getAddress();
            if (var4.indexOf(33) == -1) {
               for(int var5 = 0; var5 < var0.getNames().getCount(); ++var5) {
                  Name var6 = var0.getNames().get(var5);
                  var4 = var6.getText();
                  if (var6.getText().equals(var1.getAddress())) {
                     var4 = var6.getRefersTo();
                     break;
                  }
               }
            }

            String[] var11 = com.aspose.cells.b.a.zv.d(var4, '!');
            if (var11.length == 2 && var11[0] != null && !"".equals(var11[0]) && var11[1] != null && !"".equals(var11[1])) {
               boolean var12 = false;
               int var7 = var11[1].indexOf(":");
               if (var7 == -1) {
                  var12 = zakq.d(var11[1]);
               } else {
                  String var8 = var11[1].substring(0, 0 + var7);
                  String var9 = var11[1].substring(var7 + 1);
                  var12 = zakq.d(var8) && zakq.d(var9);
               }

               if (var12) {
                  var2[0] = var11[0];
                  var2[0] = com.aspose.cells.b.a.zv.c(var2[0], b);
                  var3[0] = (CellArea)CellArea.a(var11[1], true);
                  return true;
               }
            }
         } catch (Exception var10) {
            ;
         }
      }

      var2[0] = null;
      var3[0] = new CellArea();
      return false;
   }

   static String a(CellArea var0) {
      return "#RANGE!" + zase.a(var0);
   }

   static String g(String var0) {
      if (var0 != null && var0.length() != 0) {
         StringBuilder var1 = new StringBuilder(var0.length());

         for(int var2 = 0; var2 < var0.length(); ++var2) {
            char var3 = var0.charAt(var2);
            var1.append(d(var3));
         }

         return com.aspose.cells.b.a.zr.a(var1);
      } else {
         return "";
      }
   }

   private static String d(char var0) {
      if (var0 == '"') {
         return "\\0022";
      } else {
         return e(var0) ? "\\" + var0 : Character.toString(var0);
      }
   }

   private static boolean e(char var0) {
      switch(var0) {
      case '#':
      case '(':
      case ')':
      case ',':
      case '.':
      case '/':
      case ':':
      case ';':
      case '@':
      case '[':
      case '\\':
      case ']':
         return true;
      default:
         return false;
      }
   }

   static String a(FormatCondition var0) {
      Style var1 = var0.getStyle();
      String var2 = a(var1);
      String var3 = b(var1);
      String var4 = c(var1);
      String var5 = var2 + var3 + var4;
      if (var5.endsWith(";")) {
         var5 = var5.substring(0, 0 + (var5.length() - 1));
      }

      return var5;
   }

   static String a(Style var0) {
      if (!var0.isModified(11)) {
         return "";
      } else {
         Font var1 = var0.getFont();
         StringBuilder var2 = new StringBuilder(100);
         if (var0.isModified(16)) {
            if (var1.b.a()) {
               var2.append("color:windowtext;");
            } else {
               var2.append("color:#" + zase.a(var1.getColor()) + ";");
            }
         }

         if (var1.isItalic()) {
            var2.append("font-style:italic;");
         }

         if (var0.isModified(17)) {
            if (var1.isBold()) {
               var2.append("font-weight:700;");
            } else {
               var2.append("font-weight:400;");
            }
         }

         if (var0.isModified(19)) {
            String var3 = zbbx.b(var1.getUnderline());
            var2.append("text-underline-style:" + var3 + ";");
         }

         if (var0.isModified(20)) {
            if (var1.isStrikeout()) {
               var2.append("text-line-through:single;");
            } else {
               var2.append("text-line-through:none;");
            }
         }

         return com.aspose.cells.b.a.zr.a(var2);
      }
   }

   static String b(Style var0) {
      if (!var0.isModified(1)) {
         return "";
      } else {
         StringBuilder var1 = new StringBuilder(100);
         if (var0.f()) {
            var1.append("border-top:" + zbbx.a(var0, 4) + ";");
            var1.append("border-right:" + zbbx.a(var0, 2) + ";");
            var1.append("border-bottom:" + zbbx.a(var0, 8) + ";");
            var1.append("border-left:" + zbbx.a(var0, 1) + ";");
         } else {
            var1.append("border:none;");
         }

         return com.aspose.cells.b.a.zr.a(var1);
      }
   }

   static String c(Style var0) {
      return !var0.isModified(33) && !var0.isModified(35) && !var0.isModified(34) ? "" : zbbx.a(var0);
   }

   static String h(String var0) {
      if (var0 != null && var0.length() != 0) {
         if (var0.charAt(0) == '=') {
            return c(var0.substring(1));
         } else {
            return zapb.c(var0) ? var0 : "\"" + var0 + "\"";
         }
      } else {
         return "";
      }
   }

   static String b(FormatCondition var0) {
      String var1 = null;
      if (var0.getType() == 0 && var0.b != 6) {
         var1 = zbbx.a(var0.b);
      } else if (var0.getType() == 8) {
         var1 = "containsText";
      } else if (var0.getType() == 9) {
         var1 = "notContains";
      } else if (var0.getType() == 10) {
         var1 = "beginsWith";
      } else if (var0.getType() == 11) {
         var1 = "endsWith";
      }

      return var1;
   }

   static String a(String var0, boolean var1) {
      if (var0 == null) {
         return null;
      } else if (var0.length() == 0) {
         return var0;
      } else {
         Object var2 = a.get(var0);
         if (var2 != null) {
            return (String)var2;
         } else {
            int var3 = var0.length();
            StringBuilder var4 = new StringBuilder(var3);

            char var5;
            for(int var6 = 0; var6 < var3; ++var6) {
               var5 = var0.charAt(var6);
               switch(var5) {
               case '\n':
                  var4.append("<br>");
                  break;
               case '\r':
                  if (var6 + 1 >= var3 || var0.charAt(var6 + 1) != '\n') {
                     var4.append("</br>");
                  }
                  break;
               case '&':
                  if (var6 < var3 - 1 && var0.charAt(var6 + 1) == '#') {
                     var4.append(var5);
                     break;
                  }

                  var4.append("&amp;");
                  break;
               case '<':
                  if (var1) {
                     var4.append("&lt;");
                  } else {
                     var4.append(var5);
                  }
                  break;
               case '>':
                  if (var1) {
                     var4.append("&gt;");
                  } else {
                     var4.append(var5);
                  }
                  break;
               default:
                  var4.append(var5);
               }
            }

            var3 = var4.length();
            StringBuilder var9 = new StringBuilder(var3);
            boolean var7 = true;

            for(int var8 = 0; var8 < var3 - 1; ++var8) {
               var5 = var4.charAt(var8);
               if (var5 == ' ' && var4.charAt(var8 + 1) == ' ') {
                  if (var7) {
                     var9.append("<span style='mso-spacerun:yes'>&nbsp;");
                     var7 = false;
                  } else {
                     var9.append("&nbsp;");
                  }
               } else if (var5 == ' ' && !var7) {
                  var9.append(" </span>");
                  var7 = true;
               } else {
                  var9.append(var5);
               }
            }

            if (var3 > 0) {
               var5 = var4.charAt(var3 - 1);
               if (!var7) {
                  var9.append(" </span>");
               } else {
                  var9.append(var5);
               }
            }

            String var10 = com.aspose.cells.b.a.zr.a(var9);
            a.put(var0, var10);
            return var10;
         }
      }
   }

   public static double b(int var0, int var1) {
      return (double)((float)var1 * 72.0F / (float)var0);
   }

   public static int a(int var0, double var1) {
      return (int)(var1 * (double)var0 / 72.0D + 0.5D);
   }

   public static String e(int var0) {
      switch(var0) {
      case 0:
         return "group_";
      case 1:
         return "line_";
      case 2:
         return "rectangle_";
      case 3:
         return "oval_";
      case 4:
         return "arc_";
      case 5:
         return "chart_";
      case 6:
         return "textBox_";
      case 7:
         return "button_";
      case 8:
         return "picture_";
      case 9:
         return "polygon_";
      case 10:
      case 13:
      case 21:
      case 22:
      case 23:
      case 26:
      case 27:
      case 28:
      case 29:
      default:
         return "image_";
      case 11:
         return "checkBox_";
      case 12:
         return "radioButton_";
      case 14:
         return "label_";
      case 15:
         return "dialogBox_";
      case 16:
         return "spinner_";
      case 17:
         return "scrollBar_";
      case 18:
         return "listBox_";
      case 19:
         return "groupBox_";
      case 20:
         return "comboBox_";
      case 24:
         return "oleObject_";
      case 25:
         return "comment_";
      case 30:
         return "cellsDrawing_";
      }
   }

   public static String f(int var0) {
      switch(var0) {
      case 0:
         return "none";
      case 1:
         return "1px solid";
      case 2:
         return "2px solid";
      case 3:
         return "1px dashed";
      case 4:
         return "1px dotted";
      case 5:
         return "3px solid";
      case 6:
         return "4px double";
      case 7:
         return "1px hairline";
      case 8:
         return "2px dashed";
      case 9:
         return "1px dot-dash";
      case 10:
         return "2px dot-dash";
      case 11:
         return "1px dot-dot-dash";
      case 12:
         return "2px dot-dot-dash";
      case 13:
         return "2px dot-dash-slanted";
      default:
         throw new CellsException(6, "Invalid BorderLineStyle int val: " + var0);
      }
   }

   public static String a(Style var0, int var1, boolean var2) {
      Border var3 = var0.getBorders().getByBorderType(var1);
      int var4 = var3.getLineStyle();
      if (var4 == 0) {
         return "none";
      } else {
         StringBuilder var5 = null;
         if (var2) {
            var5 = new StringBuilder(f(var4));
         } else {
            var5 = new StringBuilder(zsl.a(var4));
         }

         if (!var3.a.a()) {
            var5.append(" #" + zase.a(var3.getColor()));
         } else {
            var5.append(" windowtext");
         }

         return com.aspose.cells.b.a.zr.a(var5);
      }
   }

   public static boolean b(Style var0, Style var1) {
      if (null == var0 && null == var1) {
         return true;
      } else if (null == var0 && null != var1) {
         return false;
      } else if (null != var0 && null == var1) {
         return false;
      } else if (var0.getClass() != var1.getClass()) {
         return false;
      } else if (!var0.getBackgroundColor().isEmpty() && !var1.getBackgroundColor().isEmpty() && (var0.getBackgroundColor().toArgb() & 16777215) != (var1.getBackgroundColor().toArgb() & 16777215)) {
         return false;
      } else if (null != var0.getBackgroundThemeColor() && null != var1.getBackgroundThemeColor() && var0.getBackgroundThemeColor().getColorType() != var1.getBackgroundThemeColor().getColorType()) {
         return false;
      } else if (null != var0.a && null != var1.a && !var0.a.a(var1.a)) {
         return false;
      } else if (!var0.getForegroundColor().isEmpty() && !var1.getForegroundColor().isEmpty() && (var0.getForegroundColor().toArgb() & 16777215) != (var1.getForegroundColor().toArgb() & 16777215)) {
         return false;
      } else if (null != var0.getForegroundThemeColor() && null != var1.getForegroundThemeColor() && var0.getForegroundThemeColor().getColorType() != var1.getForegroundThemeColor().getColorType()) {
         return false;
      } else if (null != var0.b && null != var1.b && !var0.b.a(var1.b)) {
         return false;
      } else {
         return var0.getPattern() == var1.getPattern();
      }
   }

   public static boolean a(Picture var0) {
      MsoFormatPicture var1 = var0.getFormatPicture();
      return var1 != null && (var1.getLeftCrop() != 0.0D || var1.getRightCrop() != 0.0D || var1.getTopCrop() != 0.0D || var1.getBottomCrop() != 0.0D);
   }

   public static int g(int var0) {
      switch(var0) {
      case 0:
         return 0;
      case 1:
         return 1;
      case 2:
         return 2;
      case 3:
         return 1;
      case 4:
         return 1;
      case 5:
         return 3;
      case 6:
         return 4;
      case 7:
         return 1;
      case 8:
         return 2;
      case 9:
         return 1;
      case 10:
         return 2;
      case 11:
         return 1;
      case 12:
         return 2;
      case 13:
         return 2;
      default:
         throw new CellsException(6, "Invalid BorderLineStyle int val: " + var0);
      }
   }
}
